﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CacheService.Standard
{
    public interface ICache
    {
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="content"></param>
        /// <param name="time">相对过期时间,秒</param>
        /// <returns></returns>
        void set(string key, object content, int time = 7200);
        /// <summary>
        /// 添加持久缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        void setWithLasting(string key, object content);
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="key"></param>
        /// <param name="index"></param>
        /// <param name="content"></param>
        void List(string key,int index,object content);
        /// <summary>
        /// 根据索引取item
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        T getListItem<T>(string key, int index);
        /// <summary>
        /// 取列表
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        List<T> getList<T>(string key);
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T get<T>(string key);
        /// <summary>
        /// 取出多个缓存
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        IDictionary<string, object> getMany(IEnumerable<string> keys);
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool hasKey(string key);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        void delete(string key);
    }
}
